package com.yuanchu.media.controller;

import com.yuanchu.common.utils.R;
import com.yuanchu.common.validator.ValidationGroups;
import com.yuanchu.media.dto.EditFileGroupParamsDto;
import com.yuanchu.media.dto.MoveGroupDto;
import com.yuanchu.media.entity.YoshopUploadGroupEntity;
import com.yuanchu.media.service.YoshopUploadGroupService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version: 1.0
 * @Author: adan
 * @description:
 * @date: 2024-01-26 10:54
 */
@RestController
@RequestMapping("group")
public class FileGroupController {

    @Resource
    private YoshopUploadGroupService uploadGroupService;

    @GetMapping("/list")
    public R queryGroupList() {
        List<YoshopUploadGroupEntity> list = uploadGroupService.queryGroupList();
        return R.ok().put("data", list);
    }

    @PostMapping("/add")
    public R addGroup(@RequestBody @Validated({ValidationGroups.Insert.class}) EditFileGroupParamsDto param) {
        uploadGroupService.addGroup(param);
        return R.ok();
    }

    @PostMapping("/edit")
    public R editGroup(@RequestBody @Validated({ValidationGroups.Update.class}) EditFileGroupParamsDto form) {
        uploadGroupService.editGroup(form);
        return R.ok();
    }

    @PostMapping("/move")
    public R moveGroup(@RequestBody @Validated({ValidationGroups.Update.class}) MoveGroupDto params) {
        uploadGroupService.moveGroup(params);
        return R.ok();
    }


}
